feat: relay scratch run events to the listening parent app#1496
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a new “run started” signal to the Scratch embedding flow, relaying Scratch VM run-start events from the Scratch iframe up to the parent editor app as a standard editor-runStarted custom event (per issue #1484).
Changes:
- Register a Scratch VM
PROJECT_RUN_STARTlistener in the Scratch GUI integration layer and post ascratch-gui-project-run-startedmessage to the parent window. - In the parent app, listen for
scratch-gui-project-run-startedand dispatch a correspondingeditor-runStartedCustomEvent. - Add unit tests covering listener registration/cleanup and event relay behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/components/ScratchEditor/ScratchIntegrationHOC.jsx | Hooks Scratch VM PROJECT_RUN_START to post a scratch-gui-project-run-started message. |
| src/components/ScratchEditor/ScratchIntegrationHOC.test.jsx | Tests VM listener registration/removal and message posting on run start. |
| src/components/Editor/Project/ScratchContainer.jsx | Listens for scratch-gui-project-run-started and dispatches editor-runStarted. |
| src/components/Editor/Project/ScratchContainer.test.js | Tests that the editor-runStarted event is dispatched and not dispatched after unmount. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Relates to issues:
1484
This will likely need the changes from
1483 to be seen to work full stack
There as a draft PR that will capture the even in editor-standalone -
https://github.com/RaspberryPiFoundation/editor-standalone/pull/954